<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<link id="media-sheet" rel="stylesheet" media="(min-width: 5000px)">
<link id="alternate-sheet" rel="alternate stylesheet" title="alternate">
<script>
    var test = async_test("Check that adding a non-blocking stylesheet does not cause a full document recalc.");

    window.onload = () => {
        document.body.offsetTop;

        test.step(() => {
            assert_true(!!window.internals, "Test requires internals object for recalc count.");
        });

        test.step(() => {
            document.querySelector("#media-sheet").href = "data:text/css,#x{color:pink}";
            assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 0, "No style recalc adding sheet without matching rules.");
        });

        test.step(() => {
            document.querySelector("#alternate-sheet").href = "data:text/css,*{color:pink}";
            assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 0, "No style recalc adding alternate sheet.");
        });

        test.done();
    };
</script>
